import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user:{
      token:""
    },
    checklis:[],
    classifyId: 1,//商品一级分类id
    listhot:[],
    routerList:[],
    id:"",
    address:{},
    bln:false,
  },
  getters: {
  },
  mutations: {
    SET_CHECKALL(state,payload){
      state.checklis = payload
      console.log(state.checklis);
    },
    SET_CHANGEACTIVE(state, payload) {
      state.classifyId = payload
      console.log(state.classifyId)
    },
    SET_JUMPCLICK(state, payload) {
      state.listhot= payload
      console.log(state.listhot)
    },
    SET_ROUTERLIST(state, payload) {
      state.routerList= payload
      console.log(state.routerList)
    },
    SET_DETAID(state, payload) {
      state.id= payload
      console.log(state.id)
    },
    SET_ADDRESS(state,payload){
      state.address = payload
      console.log(payload);
    },
    SET_BLN(state,payload){
      state.address = payload
      console.log(payload);
    },
    // SET_ROUTERLIST(state, payload) {
    //   state.routerList= payload
    //   console.log(state.routerList)
    // },
    SET_USER(state,payload){
      state.user.token=payload
    }
  },
  actions: {
  },
  modules: {
  },
  plugins:[createPersistedState({
    key:'jsh',
    storage:window.localStorage,
    render(state) {
      // 要存储的数据：本项目采用es6扩展运算符的方式存储了state中所有的数据
    return state.checklis

  }})]
})
